﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ServiceManager.TFSIntegration
{
    /// <summary>
    /// Interaction logic for CreateBugWindow.xaml
    /// </summary>
    public partial class CreateBugWindow : Window
    {

        private TFSBugData bugData;

        public CreateBugWindow() 
        {
        }

        public CreateBugWindow(TFSBugData data)
        {
            InitializeComponent();
            bugData = data;
            DataContext = data;

            cboCollections.Width = 125;
            cboCollections.ItemsSource = TFSService.GetCollections();
            cboCollections.SelectedIndex = 0;
            cboCollections.Items.Refresh();

            cboProjects.Width = 100;
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            this.Close();
        }

        private void cboCollections_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var id = (KeyValuePair<Guid, string>)cboCollections.SelectedItem;
            cboProjects.ItemsSource = TFSService.GetProjects(id.Key);
            cboProjects.SelectedIndex = 0;
            cboProjects.Items.Refresh();
        }

        
    }
}
